#ifndef RENDERWIDGET_H
#define RENDERWIDGET_H

#include <QGLWidget>
#include <QGLShader>
#include <QMatrix4x4>
#include <QVector3D>
#include <QBasicTimer>
#include "../QMesh/qmesh.h"
#include "../QMesh/qopenmesh.h"
#include <QMap>
#include "meshmanager.h"

class RenderWidget : public QGLWidget
{
    Q_OBJECT
public:
    explicit RenderWidget(QWidget *parent = 0);
    ~RenderWidget();

    void SetMeshManager(MeshManager* mm);

public:
    void initializeGL();
    void resizeGL(int w, int h);
    void paintGL();

    virtual void UploadMesh();

protected:
    bool m_bInitialzed;
    QBasicTimer *pMainTimer;
    void timerEvent(QTimerEvent *e);

protected:
    QGLShaderProgram m_program;

    QMatrix4x4 m_proj;
    QMatrix4x4 m_view;
    QMatrix4x4 m_model;

    QVector3D m_eye;
    QVector3D m_center;
    QVector3D m_up;

    int m_va_vertices;
    int m_va_normals;

    int m_vu_view;
    int m_vu_model;
    int m_vu_normal;
    int m_vu_eyepos;

    int m_vu_isPoint;
    int m_vu_pointColor;
    int m_vu_pointSize;

protected:
    MeshManager* m_mm;
    
signals:
    
public slots:
    
};

#endif // RENDERWIDGET_H
